// 笔试强训day24:小葱的01串

#include <iostream>
using namespace std;

int main() {
    int n = 0, one = 0, zero = 0;
    string str;
    cin >> n >> str;
    for(int i = 0; i < n; i++)
    {
        if(str[i] == '1') one++;
    }
    int hn = n / 2, hone = one / 2;
    int curone = 0, ans = 0;
    for(int i = 0; i < hn; i++)
    {
        if(str[i] == '1') curone++;
    }
    for(int i = 0; i < n; i++)
    {
        if(str[i] == '1')
            curone--;
        if(str[(i + hn) % n] == '1')
            curone++;

        if(curone == hone)
            ans++;
    }
    if(one % 2 == 0)
        cout << ans << endl;
    else
        cout << 0 << endl;
}